package com.teangtang.fly.service;

import com.teangtang.fly.entity.City;
import com.teangtang.fly.repository.CityRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class CityService {
    @Autowired
    private CityRepository cityRepository;

    public City saveCity(City city) {
        return cityRepository.save(city);
    }

    public List<City> findAllCities() {
        return cityRepository.findAll();
    }

    public City findCityByCityCode(Long cityCode) {
        return cityRepository.findByCityCode(cityCode);
    }

    public void deleteCity(Long cityCode) {
        cityRepository.deleteById(cityCode);
    }
}
